.modalBox{:id => "create_application_modalBox"}
  = form_tag apps_create_url, :id => "new-app-form", :remote => true do
    .modalBox-title=t('apps.add_app')
    .modalBox-flash
    .modalBox-content
      %table
        %tbody
          %tr
            %td
              = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.name_help_html'))
              = label_tag "name", t('apps.name') + ":"
            %td
              = text_field_tag :name, @name, :size => 50, :required => "required", :autofocus => "autofocus",
                :placeholder => t('apps.name_placeholder'), :pattern => "[a-zA-Z0-9-_]+", :title => t('apps.name_title_html')
              .form-field-error
          %tr
            %td
              = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.instances_num_help_html'))
              = label_tag "instances", t('apps.instances_num') + ":"
            %td
              = number_field_tag :instances, @instances, :min => 1, :max => @available_instances, :required => "required"
              .form-field-error
          %tr
            %td
              = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.memory_size_help_html'))
              = label_tag "memsize", t('apps.memory_size') + ":"
            %td
              = select_tag :memsize, options_for_select(@available_memsizes), :required => "required",
                :class => "memory-chosen", :style => "width: 100px;"
              .form-field-error
          %tr
            %td
              = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.type_help_html'))
              = label_tag "type", t('apps.type') + ":"
            %td
              = select_tag :type, options_for_select(@available_frameworks), :required => "required",
                :class => "type-chosen", :style => "width: 300px;"
              .form-field-error
          %tr
            %td
              = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.url_help_html'))
              = label_tag "url", t('apps.url') + ":"
            %td
              = url_field_tag :url, @url, :size => 50, :required => "required", :placeholder => t('apps.url_placeholder')
              .form-field-error
    .modalBox-title=t('apps.optional_data')
    .modalBox-content
      %table
        %tbody
          %tr
            %td
              = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.bind_service_help_html'))
              = label_tag "service", t('apps.bind_service') + ":"
            %td
              = select_tag :service, options_for_select(@available_services), :class => "service-chosen", :style => "width: 300px;"
              .form-field-error
          - if git_deploy_available?
            %tr
              %td
                = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.deploy_from_help_html'))
                = label_tag "deployfrom", t('apps.deploy_from') + ":"
              %td
                = radio_button_tag :deployfrom, 'git', true, :disabled => true
                = t('apps.git')
            %tr
              %td
                = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.git_repo_help_html'))
                = label_tag "gitrepo", t('apps.git_repo') + ":"
              %td
                = text_field_tag :gitrepo, @gitrepo, :size => 50, :placeholder => t('apps.git_repo_placeholder'),
                  :pattern => "(git://[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(([0-9]{1,5})?.*)?.git)?",
                  :title => t('apps.git_repo_title_html')
                .form-field-error
            %tr
              %td
                = sprite_tag("help", :alt => "?", :class=> "help", :title => t('apps.git_branch_help_html'))
                = label_tag "gitrepo", t('apps.git_branch') + ":"
              %td
                = text_field_tag :gitbranch, @gitbranch, :size => 20, :placeholder => t('apps.git_branch_placeholder')
                .form-field-error
    .modalBox-submit= submit_tag t('apps.add_app')

- if @newapp_default_urldomain
  - content_for :javascripts do
    :javascript
      $(function() {
        $(document)
          .on('focus', '#new-app-form input#url', function() {
            if ($(this).val() == "") {
              var app_name = $('#new-app-form input#name');
              $(this).val('http://' + app_name.val() + '.#{@newapp_default_urldomain}');
            }
          });
      });